/**
 * Created by Toma on 2016/12/9.
 *
 * 类， 继承， 泛型
 */

class Person{
    public name; // 默认都是public
    constructor(name:string){
        this.name = name;
    };
    eat(){
        console.log(this.name);
    };
    private play = 'coco'; // 私有的
    protected coco(){
        return this.play;
    }; // 仅有自己和子类可访问
}

class Employee extends Person{
    code:string;
    constructor(name:string,code:string){
        super(name); // 调用父类
        this.code = code;
    };
    work(){
        console.log(this.coco());
        console.log(this.code);
        super.eat();
    }
}

var p1 = new Person('batMan');
p1.eat();

var p2 = new Employee('supperMan','pop');
p2.work();


// 泛型
var works: Array<Person> = [];
works[0] = p1;
works[1] = p2;